package Roboter;

import lejos.nxt.SensorPort;

public class Elektromagnet {
	private boolean elektromagnetEingeschaltet;

	public Elektromagnet() {
		this.elektromagnetEingeschaltet = false;
		
		SensorPort.S4.setPowerType(SensorPort.POWER_9V);
		SensorPort.S4.setTypeAndMode(SensorPort.SP_DIGI0, SensorPort.SP_MODE_OUTPUT);
		SensorPort.S4.setSensorPin(SensorPort.SP_DIGI0, 0); 
	}

	public void schalten() {
		if (this.elektromagnetEingeschaltet) {
			
			SensorPort.S4.setSensorPin(SensorPort.SP_DIGI0, 0);
			
			this.elektromagnetEingeschaltet = false;
		} else {
			
			SensorPort.S4.setSensorPin(SensorPort.SP_DIGI0, 1);
			
			this.elektromagnetEingeschaltet = true;
		}
	}
}
